package com.kaifamiao.json;

import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import java.io.IOException;
import java.time.LocalDate;

public class BirthdateDeserializer extends JsonDeserializer<LocalDate> {

    @Override
    public LocalDate deserialize(JsonParser parser, DeserializationContext context) throws IOException, JacksonException {
        String text = parser.getText(); // 获得客户端传递过来的值
        return LocalDate.parse(text); // 将 YYYY-MM-DD 格式的字符串解析为 LocalDate
    }

}
